package com.zx.mes.rabbitmq.hyl.controller;

import com.zx.mes.rabbitmq.entity.Message;
import com.zx.mes.rabbitmq.entity.Order;
import com.zx.mes.rabbitmq.hyl.send.RabbitSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * 控制器 senderController
 * @author huayunlong
 * @date 2018-8-6
 */
@RestController
public class SenderController {

    @Autowired
    private RabbitSender rabbitSender;

    @RequestMapping("/sender")
    public void sender(){
        Order order = new Order();
        order.setId(UUID.randomUUID().toString());
        order.setName("神一般的人物");
        Message<Order> message = new Message<>();
        message.setMessage(order);
        Map<String, Object> map = new HashMap<>(2);
        map.put("page", 0);
        map.put("limit", 10);

        Order order2 = new Order();
        order2.setName("天地任我行");
        order2.setId(null);
        message.setMap(map);
        message.getList().add(order2);
        message.getList().add(order);
        this.rabbitSender.sender(message);

    }

    @RequestMapping("/senderOrder")
    public void senderOrder(){
        Order order = new Order();
        order.setId(UUID.randomUUID().toString());
        order.setName("神一般的人物");

        this.rabbitSender.senderOrder(order);

    }


}
